﻿// JScript File

function validateMaxLen(field, maxLength)
{
	if (field.value.length > maxLength)
	{
			field.value = field.value.substring(0, maxLength);
	}
}


function acceptNum(evt){	
// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57	
var key = nav4 ? evt.which : evt.keyCode;
return (key <= 13 || (key >= 48 && key <= 57));
}

function acceptChar(evt){	
// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57	
var key = nav4 ? evt.which : evt.keyCode;
return ( !( (key >= 1 && key <= 31) || (key >= 33 && key <= 45) || (key==47) || (key >= 58 && key <= 63) || (key >= 91 && key <= 96) || 
						(key >= 123 && key <=129) || (key >= 131 && key <= 192) || (key >= 194 && key <=200) || (key >= 255) ) );
}


// Acept:a Numeros, Letras, punto y Arroba
function acceptCharMail(evt){
var key = nav4 ? evt.which : evt.keyCode;

return ( !( (key >= 1 && key <= 31) || (key >= 33 && key <= 44) || (key==47) || (key >= 58 && key <= 63) || (key >= 91 && key <= 94) || (key == 96) || (key >= 123 && key <=129) || (key >= 131 && key <= 192) || (key >= 194 && key <=200) || (key==209) || (key==241) || (key >= 255) ) );
}

function acceptCharURL(evt){	
var key = nav4 ? evt.which : evt.keyCode;
return ( !( (key >= 1 && key <= 31) || (key >= 33 && key <= 45) || (key >= 59 && key <= 63) || (key >= 91 && key <= 94) ||  (key == 96) ||
						(key >= 123 && key <=129) || (key >= 131 && key <= 192) || (key >= 194 && key <=200) || (key >= 255) ) );
}

function acceptCharDir(evt){	
var key = nav4 ? evt.which : evt.keyCode;
return (!( (key >= 1 && key <= 31) || (key == 60) || (key == 62) ) );
}

function acceptAddress(evt){	
// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57	
var key = nav4 ? evt.which : evt.keyCode;
return (acceptNum(evt) || !( (key >= 33 && key <= 44) || (key >= 58 && key <= 63) || (key >= 91 && key <= 94) || (key==96) || (key >= 123 && key <=208) || (key >= 210 && key <=240) ));
}

function validarNumeros(e) {
        tecla = (document.all)?e.keyCode:e.which;
        if (tecla==8) return true;
        patron = /\d/;
        return patron.test(String.fromCharCode(tecla));
}

function checkDecimalControl(control,keyCodeDecSing)
{	
	if (control.value.length > 0)
	{				
		var result = true;
		
		if (keyCodeDecSing == 44)
			result = /^\d+(\,\d+)?$/.test(control.value);
		else if (keyCodeDecSing == 46)
			result = /^\d+(\.\d+)?$/.test(control.value);
		 
		if (!result)
		{
			alert("Este no es un numero decimal valido. Por favor verifique.");
			control.focus();
			return false;
		}
	}
	
	return true;	
}